package com.oocl.eventListener;

import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.io.ObjectOutputStream;

import com.oocl.tm.log4j.Log4j;
import com.oocl.tm.protocol.MsgPackage;
import com.oocl.tm.protocol.Operation;
import com.oocl.tm.ui.ChatFrame;

public class ShakeButtonListener implements ActionListener{
	
	private ObjectOutputStream out;
	private String name;
	private String receiver;
	private ChatFrame window;
	
	
	public ShakeButtonListener(ObjectOutputStream out,String name, String receiver, ChatFrame window){
		this.out = out;
		this.name = name;
		this.receiver = receiver;
		this.window = window;
		
	}

	public void actionPerformed(ActionEvent e) {
		
		try {
			MsgPackage msg = new MsgPackage(Operation.SHAKE, name, window.getReceiver(), null, null, null);
			out.writeObject(msg);
			Log4j.getLogger().info(name + " shake "+receiver + "!!!");
		} catch (IOException e1) {
			Log4j.getLogger().info(name + " shake "+receiver + "occur error!");
		}
	}
	


}
